package com.by.bean;

import com.by.common.group.ISave;
import com.by.common.group.IUpdate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author wang
 * @version 版本号 ${}
 * @className User
 * @日期 2024/9/4 16:00
 * @since jdk1.8
 */
@ApiModel ("用户")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    
    @NotNull (message = "修改时用户id不能为空", groups = {IUpdate.class})
    @ApiModelProperty (name = "id", value = "用户id", required = false)
    int id;
    
    @NotNull (message = "用户名不能为空", groups = {ISave.class, IUpdate.class})
    @Length (min = 3, message = "用户名至少三位", groups = {ISave.class, IUpdate.class})
    @ApiModelProperty (name = "account", value = "用户名", required = false)
    String account;
    
    /*@NotBlank(message = "密码不能为空")*/
    @NotNull (message = "密码不能为空", groups = {ISave.class, IUpdate.class})
    @Pattern (regexp = "[a-zA-Z0-9_]{6,12}", message = "密码由字母、数字、下划线组成的8-12位字符",groups = {ISave.class, IUpdate.class})
    @ApiModelProperty (name = "password", value = "密码", required = false)
    @NotNull
    String password;
    
    @ApiModelProperty(value = "用户类型",hidden = true)
    int type;
    
    
    public String getAccount() {
        return account;
    }
    
    public void setAccount(String account) {
        this.account = account;
    }
}
